package com.zjsru.oneDay;

/**
 * 1550. 存在连续三个奇数的数组
 *
 * @Author: cookLee
 * @Date: 2025-05-11
 */
public class ThreeConsecutiveOdds {

    /**
     * 主
     * \
     * 输入：arr = [2,6,4,1]
     * 输出：false
     * 解释：不存在连续三个元素都是奇数的情况。
     * \
     * 输入：arr = [1,2,34,3,4,5,7,23,12]
     * 输出：true
     * 解释：存在连续三个元素都是奇数的情况，即 [5,7,23] 。
     * \
     *
     * @param args args
     */
    public static void main(String[] args) {
        ThreeConsecutiveOdds threeConsecutiveOdds = new ThreeConsecutiveOdds();
        System.out.println(threeConsecutiveOdds.threeConsecutiveOdds(new int[]{1, 2, 34,}));
    }

    public boolean threeConsecutiveOdds(int[] arr) {
        int count = 0;
        for (int number : arr) {
            if (number % 2 == 1) {
                count++;
            } else {
                count = 0;
            }
            if (count == 3) {
                return true;
            }
        }
        return false;
    }

}
